# -*- coding : utf-8 -*-
# author : Big Cat
# time : 2021/7/25:22:45
# file : getdatas.py
import os

import jsonpath
import yaml

from comm import dir_config as Dir

class Data:

    def __init__(self,key=None,filename='testdatas.yml'):
        filepath = os.path.join(Dir.testdata_dir,filename)
        with open(filepath,encoding='utf-8') as yaml_file:
            self.datas = yaml.load(yaml_file,Loader=yaml.FullLoader)
            if key != None:
                self.data = jsonpath.jsonpath(self.datas,f'$..{key}')






def readYaml(filename,key):
    filepath = os.path.join(Dir.testdata_dir,filename)
    with open(filepath,encoding='utf-8') as yaml_file:
        datas = yaml.load(yaml_file,Loader=yaml.FullLoader)
        return datas[key]


# print(readYaml('testdatas.yml','goodsPay'))
if __name__ == '__main__':
    testdata = Data(filename='login.yml').datas
    print(testdata)